package com.cyy.springbootinit.model.vo;

import cn.hutool.json.JSONUtil;
import com.cyy.springbootinit.model.entity.ReadingHistory;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 抄表历史表视图
 *
 * @author 程序员cyy</a>
 * @from cyy</a>
 */
@Data
public class ReadingHistoryVO implements Serializable {

    private Integer historyId;

    /**
     * 整数，设备ID（通过关联表实现关联，此处暂不体现外键）
     */
    private Integer equipmentId;

    /**
     * 日期，抄表日期
     */
    private Date readingDate;

    /**
     * 浮点数，当前读表数据
     */
    private Double readingValue;

    /**
     * 字符串，备注信息（如抄表时的特殊情况等）
     */
    private String remarks;

    /**
     * 封装类转对象
     *
     * @param readingHistoryVO
     * @return
     */
    public static ReadingHistory voToObj(ReadingHistoryVO readingHistoryVO) {
        if (readingHistoryVO == null) {
            return null;
        }
        ReadingHistory readingHistory = new ReadingHistory();
        BeanUtils.copyProperties(readingHistoryVO, readingHistory);
        return readingHistory;
    }

    /**
     * 对象转封装类
     *
     * @param readingHistory
     * @return
     */
    public static ReadingHistoryVO objToVo(ReadingHistory readingHistory) {
        if (readingHistory == null) {
            return null;
        }
        ReadingHistoryVO readingHistoryVO = new ReadingHistoryVO();
        BeanUtils.copyProperties(readingHistory, readingHistoryVO);
        return readingHistoryVO;
    }
}
